package com.kl.modular.sysman.system.controller;

import com.alibaba.fastjson.JSON;
import com.kl.common.pager.PageParameter;
import com.kl.common.pager.Pager;
import com.kl.modular.common.controller.BaseController;
import com.kl.modular.system.dao.bo.SystemLogBo;
import com.kl.modular.system.dao.model.SystemLog;
import com.kl.modular.system.service.api.ISystemLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;

/**
 * 操作日志控制器
 * @author kl_zjb
 * @date 2017-01-17 16:48
 * @(C) kongling Copyright 
 */
@Controller
public class SystemLogController extends BaseController {
	
	private static final Logger logger = LoggerFactory.getLogger(SystemLogController.class);
	
	@Autowired
	private ISystemLogService systemLogService;
	
	/** 操作日志 view */
	private static String pathSystemLogRoot="/sysman/system/log/";
	
	
	/**
	 * 操作日志列表页面
	 */
	@RequestMapping(value = "/sysman/systemLog/systemLogList", method = RequestMethod.GET)
	@RequiresPermissions("sysman:SYSTEM_LOG:viewlist")
	public String queryList(HttpServletRequest request) throws Exception{
		logger.info("操作日志列表页面");
		//proBusinessServiceService.selectPanServiceAuth(ProServiceConstant.PRO_SERVICE_CODE_SYSTEM_LOG, getBussinessId());
		return pathSystemLogRoot + "systemLogList.jsp";
	}

	/**
	 * 操作日志列表数据
	 */
	@RequestMapping(value = "/sysman/systemLog/systemLogAjaxList", method = RequestMethod.POST)
	@RequiresPermissions("sysman:SYSTEM_LOG:viewlist")
	public String queryAjaxList(SystemLogBo systemLogBo, PageParameter pageParameter , HttpServletRequest request) throws Exception{
		logger.info("systemLog列表数据>>data:" + JSON.toJSONString(systemLogBo));
//		//proBusinessServiceService.selectPanServiceAuth(ProServiceConstant.PRO_SERVICE_CODE_SYSTEM_LOG, getBussinessId());
//		if (systemLogBo == null) {
//			systemLogBo = new SystemLogBo();
//		}
//		if(pageParameter == null){
//			pageParameter = new PageParameter();
//		}
//		Pager<SystemLog> page = systemLogService.getListByBoPage(systemLogBo,pageParameter);
//		request.setAttribute("pager", page);
		return pathSystemLogRoot + "systemLogAjaxList.jsp";
	}

	/**
	 * 操作数据
	 * @param id
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/sysman/systemLog/viewData" , method = RequestMethod.GET)
	@RequiresPermissions("sysman:SYSTEM_LOG:viewData")
	public String viewData(Long id, HttpServletRequest request){
//		if(id == null){
//			return null;
//		}
//		SystemLogBo systemLogBo = new SystemLogBo();
//		systemLogBo.setId(id);
//		SystemLog systemLog = systemLogService.findSystemLogByBo(systemLogBo);
//		request.setAttribute("item", systemLog);
		return pathSystemLogRoot + "viewData.ftl";
	}
	
}
